//
//  Method2View.swift
//  corner_shadow
//
//  Created by 李煜 on 2024/5/13.
//

import UIKit

class Method2View: UIView {
    let contentView: UIView = UIView()
    override init(frame: CGRect) {
        super.init(frame: frame)
        // 方式二: contentView设置圆角+自身设置阴影

        addSubview(contentView)

        layer.shadowColor = UIColor.black.cgColor
        layer.shadowOffset = CGSize(width: 2, height: 2)
        layer.shadowOpacity = 0.5
        layer.shadowRadius = 2
        // contentView设置圆角
        contentView.backgroundColor = .white
        contentView.frame = bounds
        contentView.layer.cornerRadius = 30
        contentView.layer.masksToBounds = true
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
